package com.hubu.tree;
import com.hubu.tree.util.Comparator;
import com.hubu.tree.util.Visitor;
public class AvlTree<T> extends BinarySearchTree<T>{
    public AvlTree(Comparator<T> comparator, Visitor<T> visitor) {
        super(comparator, visitor);
    }
    @Override
    public TreeNode<T> createNode(T value, TreeNode<T> left, TreeNode<T> right) {
        TreeNode<T> node=new AvlNode<>(value,null,null,null,1);
        return node;
    }
    public static class AvlNode<T> extends BinarySearchTreeNode<T>{
        private int height;
        public AvlNode(T value, TreeNode<T> left, TreeNode<T> right, TreeNode<T> parent,int height) {
            super(value, left, right, parent);
        }
    }


    /**
     *
     * Avl树 添加之后需要调
     * @param node
     */

    @Override
    public void afterAdd(TreeNode<T> node) {

    }

    @Override
    public void connectParent(TreeNode<T> parent, TreeNode<T> newNode) {
        ((AvlNode<T>)newNode).parent=parent;
    }
}
